<script setup>
import { ref, onMounted, isMemoSame } from 'vue'
import { getOwnFinanceAPI } from '@/apis/finance'

const finance = ref({})
const imgs = ref([])
onMounted(async () => {
    const res = await getOwnFinanceAPI()
    if (res.code === 2000) {
        finance.value = res.data
        imgs.value = finance.value.fileInfo.split(',')
        imgs.value.pop()
        console.log(imgs.value);
    }
})
</script>

<template>
<div class="finance-page">
    <div class="page-title">我的融资</div>
    <div class="apply-wrapper" v-if="finance.id">
        <div class="apply-form">
            <el-form label-width="100px">
                <el-form-item label="状态">
                    <span style="color: #e6a23c;" v-show="finance.status === 0">待审核</span>
                    <span style="color: #f56c6c;" v-show="finance.status === 2">申请驳回</span>
                    <span style="color: #45b035;" v-show="finance.status === 1">申请通过</span>
                </el-form-item>
                <el-form-item label="姓名">
                    <el-input v-model="finance.realName" :disabled="true" />
                </el-form-item>
                <el-form-item label="融资额度">
                    <el-input v-model="finance.money" :disabled="true" />
                </el-form-item>
                <el-form-item label="利息">
                    <el-input v-model="finance.rate" :disabled="true" />
                </el-form-item>
                <el-form-item label="意向借款期">
                    <el-input v-model="finance.repayment" :disabled="true" />
                </el-form-item>
                <el-form-item label="联系方式">
                    <el-input v-model="finance.phone" :disabled="true" />
                </el-form-item>
                <el-form-item label="身份证号">
                    <el-input v-model="finance.combinationIdnum1" :disabled="true" />
                </el-form-item>
                <el-form-item label="上传材料">
                    <template v-for="(img, i) in imgs" :key="i">
                        <img :src="img" alt="">
                    </template>
                </el-form-item>
            </el-form>
        </div>
    </div>
    <div class="empty" style="margin-top: 50px;" v-else>
        暂无融资信息
    </div>
</div>
</template>

<style scoped lang='scss'>
.finance-page {
    width: 100%;
    height: 100%;
    min-height: 600px;
    margin: 20px auto;
    padding: 20px 40px;
    background-color: #fff;
}

.page-title {
    font-size: 21px;
    padding: 15px 0;
    border-bottom: 1px solid #e8e8e8;
}

.apply-form {
    width: 700px;
    min-height: 400px;
    padding: 10px;

    img {
        height: 300px;
        margin-bottom: 10px;
    }
}
</style>
